%% https://svn.kwarc.info/repos/arXMLiv/trunk/sty/yacc.sty
%%                                                       -*- LaTeX -*-
%% Language definition of Yacc/Bison for listings package
%%

%% Yacc
\lstdefinelanguage[]{Yacc}%
  {otherkeywords=%
    {\%left,
      \%nonassoc,\%prec,\%right,
      \%start,\%token,\%type,\%union,
      \%\%,\%\{,\%\},|,:,
      \$\$,\$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9
    },%
    keywords={\%seeREADME},%
    morecomment=[n]{/*}{*/},%
    morestring=[b]{"},%
    sensitive=true
  }[keywords,comments,strings]%


%% Yacc: Bison

%% Listings does not support ``moreotherkeywords'', so we cannot
%% simply inherit.  To bad for code duplication.
\lstdefinelanguage[Bison]{Yacc}%
  {otherkeywords=%
    {\%binary,\%debug,\%default-prec,\%define,\%defines,\%destructor,
      \%dprec,\%error-verbose,\%expect,\%expect-rr,\%file-prefix,
      \%fixed-output-files,\%initial-action,\%glr-parser,
      \%language,\%left,
      \%lex-param,\%locations,\%merge,\%name-prefix,\%no-default-prec,
      \%no-lines,\%nonassoc,\%nondeterministic-parser,\%nterm,\%output,
      \%parse-param,\%prec,\%printer,\%pure-parser,\%right,\%skeleton,
      \%start,\%term,\%token,\%token-table,\%type,\%union,\%verbose,\%yacc,
      \%\%,\%\{,\%\},|,:,
      \$\$,\$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,
      @\$,@1,@2,@3,@4,@5,@6,@7,@8,@9
    },%
    keywords={\%seeREADME},%
    morecomment=[n]{/*}{*/},%
    morecomment=[s]{//},%
    morestring=[b]{"},%
    sensitive=true
  }[keywords,comments,strings]%

\lstdefinelanguage{Bison}[Bison]{Yacc}{}
